#include "Head.h"

Global::Global(int argc,char *argv[])
{	
	char * confile="F:\\verydm.conf";
	int pos=1;
	while(pos<argc)
	{
		if (!strcmp(argv[pos],"-c")&& argc>pos+1)
		{
			confile=argv[pos+1];
			pos+=2;
		}
		else
			break;
	}
	if(pos!=argc)
	{
		cerr<<"usage: "<<argv[0];
		exit(1);
	}
	else
		cout<<"The configure file: "<<confile<<endl;

	ParseFile(string(confile));
}

Global::~Global()
{

}

void Global::ParseFile(string confile)
{
	fstream fin(confile);
	string::size_type startpos=0,endpos=0;
	if(!fin.is_open())
	{
		cerr << "cannot open config file (" << confile << ") : "
			<< strerror(errno) << endl;
		exit(1);
	}
	string word;
	while (getline(fin,word))
	{
		if((startpos=word.find("#"))!=string::npos||word.length()==0)
			continue;
		else
		{
			word=Trim(word);
			if (word.find("Associate")!=string::npos)
			{
				cout<<word<<endl;
				Associate_init();
			}
			else
			{
				if (word.find("Classify"))
				{
					cout<<"Classify"<<endl;
				}
			}

		}
		startpos=0;
	}
	fin.close();
}

